#include <iostream>
#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>
#include "Task.hpp"
#include "LockGuard.hpp"
#include "PthreadPool.hpp"
#include "Thread.hpp"

using namespace ThreadNS;

int main()
{
    //主线程用来生产,由主线程来进行push
    int x,y;
    char op,admir;

    //PthreadPool<Task> PQ(5);
    //PQ.run();

    PthreadPool<Task>::getSingleClass()->run();
    while(1)
    {
        // 这样可以避免乱打印
        sleep(1);

         std::cout << "输入左操作数 #";
         std::cin >> x;
        //std::cout <<  std::endl;

         std::cout << "输入右操作数 #";
         std::cin >> y;
         //std::cout << std::endl;

         std:: cout << "运算方式? #";
         std::cin >> op;
         //std::cout << std::endl;

         std::cout << "确认运行吗 ? [yse/no] ";
         std::cin >> admir;
         //std::cout << std::endl;

         if(admir == 'y')
         { 
             Task _task(x,y,op,mymath);
          
             PthreadPool<Task>::getSingleClass()->push(_task);
         }

       
    }
    return 0;
}